package others;

import java.util.Collection;

/**
 * @author ycz
 * @date 2021/5/31
 * @description TODO
 *
 */
public class extendsTest {

    public static class parent {
        public void print() {
            System.out.println("parent ");
        }
    }


    public static class pet extends parent {
        @Override
        public void print() {
            System.out.println("pet ");
        }
    }

    public static class cat extends pet {
        @Override
        public void print() {
            System.out.println("cat ");
        }
    }

    public static class dog extends pet {
        public void test() {
            super.print();
        }

        @Override
        public void print() {
            System.out.println("dog ");
        }
    }


    public static void main(String[] args) {

        pet[] pets = new pet[]{new cat(), new dog(), new pet()};
        for (int i = 0; i < 3; i++) {
            pets[i].print();
        }
        dog dog = new dog();
        dog.test();
    }

}
